package com.ruoyi.gateway.config;

import com.ruoyi.gateway.handler.XyslCodeHandler;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.server.RequestPredicates;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.RouterFunctions;
import com.ruoyi.gateway.handler.ValidateCodeHandler;

/**
 * 路由配置信息
 *
 * @author ruoyi
 */
@Configuration
public class RouterFunctionConfiguration
{
    @Autowired
    private ValidateCodeHandler validateCodeHandler;

    @Autowired
    private XyslCodeHandler xyslCodeHandler;

    @SuppressWarnings("rawtypes")
    @Bean
    public RouterFunction routerFunction() {
        return RouterFunctions
                .route(RequestPredicates.GET("/code")
                                .and(RequestPredicates.accept(MediaType.TEXT_PLAIN)),
                        validateCodeHandler)  // 处理 /code 的逻辑

                .andRoute(RequestPredicates.GET("/xyslCode")
                                .and(RequestPredicates.accept(MediaType.TEXT_PLAIN)),
                        xyslCodeHandler);  // 处理 /xyslCode 的逻辑
    }


}
